<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 13415372994
  Date: 2024/1/3
  Time: 19:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>二手车管理系统</title>
</head>
<body>
<h1>二手车管理系统</h1>
<form method="post" action="${pageContext.request.contextPath}/list">
    <p>
        车名：<input type="text" name="name">
        车型：
        <select name="type">
            <option value="">-请选择-</option>
            <option value="1">轿车</option>
            <option value="2">SUV</option>
        </select>
        <input type="submit" value="查询">
    </p>
    <table border="1" style="text-align: center">
        <tr style="background-color: #ccc">
            <th>车名</th>
            <th>车价(万)</th>
            <th>里程</th>
            <th>购车时间</th>
            <th>车型</th>
            <th>车辆状态</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${list}" var="car">
            <tr>
                <td>${car.carName}</td>
                <td>${car.carPrice}</td>
                <td>${car.carMileage}</td>
                <td>${car.carBuyTime}</td>
                <td>
                        ${car.carType == 1 ? "轿车" : "SUV"}
                </td>
                <td>
                        ${car.carStatus == 1 ? "在售" : "已售"}
                </td>
                <td><a href="${pageContext.request.contextPath}/detail?id=${car.carId}">修改</a></td>
            </tr>
        </c:forEach>
    </table>

    <a href="${pageContext.request.contextPath}/list?name=${name}&type=${type}&currPage=1&pageSize=${pageSize}">首页</a>
    <a href="${pageContext.request.contextPath}/list?name=${name}&type=${type}&currPage=${currPage - 1}&pageSize=${pageSize}">上一页</a>
    <a href="${pageContext.request.contextPath}/list?name=${name}&type=${type}&currPage=${currPage + 1}&pageSize=${pageSize}">下一页</a>
    <a href="${pageContext.request.contextPath}/list?name=${name}&type=${type}&currPage=${totalPage}&pageSize=${pageSize}">末页</a>
    当前显示第${currPage}页，总页数${totalPage}页，共${count}条记录
</form>
</body>
</html>
